package com.tuananh.radnom.model.protocol.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Observable;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;

import org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode;

import com.tuananh.radnom.model.iputils.IPRange;

@XmlDiscriminatorNode("@class")
public abstract class AbstractDiscover extends Observable implements Runnable{
	boolean enable;
	@XmlAttribute
	public boolean isEnable() {
		return enable;
	}

	public void setEnable(boolean enable) {
		this.enable = enable;
	}

	boolean broadcast;

	@XmlAttribute
	public boolean isBroadcast() {
		return broadcast;
	}

	public void setBroadcast(boolean broadcast) {
		this.broadcast = broadcast;
	}

	String inputIPs;

	@XmlElement(name = "input")
	public String getInputIPs() {
		return inputIPs;
	}

	public void setInputIPs(String inputIPs) {
		this.inputIPs = inputIPs;
	}

	String broadcastConfig;

	@XmlElement(name = "broadcast-input")
	public String getBroadcastConfig() {
		return broadcastConfig;
	}

	public void setBroadcastConfig(String broadcastConfig) {
		this.broadcastConfig = broadcastConfig;
	}

	ArrayList<IPRange> range;

	@XmlElementWrapper(name = "config")
	@XmlElement(name = "range")
	public ArrayList<IPRange> getRange() {
		return range;
	}

	public void setRange(ArrayList<IPRange> range) {
		this.range = range;
	}

	public abstract ArrayList<String> broadcastDiscover(
			);

	public abstract ArrayList<String> discoverNetInt();

	public abstract HashMap<String, String> discoverType(
			ArrayList<String> discoveredIPs);

	public abstract HashMap<String, String> discoverConnection(
			ArrayList<String> inputIPs);
	protected void updateObservers(Object arg){
		this.setChanged();
		this.notifyObservers(arg);
		this.clearChanged();
	}
}
